package com.zryc.shop.client;

import com.zryc.shop.pojo.Product;
import com.zryc.shop.util.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

// name属性定义我们要调用的服务ID（在nacos中注册的服务ID）
@FeignClient(name = "shop-product", fallback = ProductServiceClientExceptionHandler.class)
@Primary
public interface ProductServiceClient {
    @GetMapping("/product/{pid}")
    Product detail(@PathVariable Integer pid);

    @PostMapping("/product/subStock")
    ResponseResult subStock(@RequestParam Integer pid, @RequestParam Integer num);
}
